//
//  LALoginViewController.m
//  FMDB_Demo_Login
//
//  Created by libertyair on 15/5/28.
//  Copyright (c) 2015年 libertyair. All rights reserved.
//

#import "LALoginViewController.h"
#import "LARegistViewController.h"
#import "IDTools.h"
#import "User.h"
#import "MainViewController.h"
#import "YRSideViewController.h"
#import "LANavigationController.h"
#import "LALeftTableViewController.h"

@interface LALoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *password;

@end

@implementation LALoginViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

- (IBAction)loginClick:(UIButton *)sender
{ //点击登陆按钮
    
    
    User *user = [User UserWithUserName:self.userName.text andPassword:self.password.text];
    if([IDTools verification:user])
    {
        LALog(@"登陆成功");

        [self login];
    }
}

- (IBAction)registClick:(UIButton *)sender   //点击立即注册按钮
{
    LARegistViewController *registVC = [[LARegistViewController alloc]init];
    LANavigationController *navigation = [[LANavigationController alloc]initWithRootViewController:registVC];
    [self presentViewController:navigation animated:YES completion:^{
        ;
    }];
}

- (IBAction)testID:(id)sender
{
    [self login];
}

#pragma mark - 登陆
- (void)login
{
    //抽屉
    MainViewController *mainVC = [[MainViewController alloc]init];
    LANavigationController *mainNC = [[LANavigationController alloc]initWithRootViewController:mainVC];
    //主要的
    YRSideViewController *sideVC = [[YRSideViewController alloc]init];
    sideVC.rootViewController = mainNC;
    //左边的
    LALeftTableViewController *leftVC = [[LALeftTableViewController alloc]init];
    LANavigationController *leftNC = [[LANavigationController alloc]initWithRootViewController:leftVC];
    sideVC.leftViewController = leftNC;
    
    [self presentViewController:sideVC animated:YES completion:^{
        ;
    }];
    
    [sideVC setRootViewMoveBlock:^(UIView *rootView, CGRect orginFrame, CGFloat xoffset) {
        //使用简单的平移动画
        rootView.frame=CGRectMake(xoffset, orginFrame.origin.y, orginFrame.size.width, orginFrame.size.height);
        
        LALog(@"%f,%f,%f,%f",xoffset,orginFrame.origin.y,orginFrame.size.width,orginFrame.size.height);
    }];
}

@end




















